//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_tkkickcheck.sqf"
#include "x_setup.sqf"

private ["_tk", "_p", "_sel", "_numtk", "_uid"];
__TRACE_1("_this","_this");
_tk = _this select 2;
//TYRGHEN
if ((if (isnil "mp_rights_fnc_hasRoles") then { false } else { __TRACE_1("Check rights","[_tk] call mp_rights_fnc_isMember"); (([_tk] call mp_rights_fnc_isMember)) }) ) exitWith {_tk addScore ((GVAR(sub_tk_points) / 2) * -1)};
_tk addScore (GVAR(sub_tk_points) * -1);
_uid = getPlayerUID _tk;
__TRACE_2("TKKickCheck","_tk","_uid");
_p = GV2(GVAR(player_store),_uid);

if (!isNil "_p") then {
	_numtk = _p select 7;
	__INC(_numtk);
	_p set [7, _numtk];
	if (GVAR(domdatabase)) then {
		_p set [16, (_p select 16) + 1];
	};
	if (_numtk >= GVAR(maxnum_tks_forkick)) exitWith {
		_pna = _p select 6;
		serverCommand ("#kick " + _pna);
		diag_log format ["Player %1 was kicked automatically because of teamkilling, # team kills: %3, ArmA 2 Key: %2", _pna, _uid, _numtk];
		[QGVAR(tk_an), [_pna, _numtk]] call FUNC(NetCallEventToClients);
		[QGVAR(em), [_tk]] call FUNC(NetCallEventSTO);
	};
};